
<html>
<head>
<title>login</title>
	<link rel="stylesheet" type="text/css" href="<?php echo base_url(); ?>public/css/bootstrap.min.css">
	<link rel="stylesheet" type="text/css" href="<?php echo base_url(); ?>public/css/bootstrap-theme.min.css">
	<link rel="stylesheet" type="text/css" href="<?php echo base_url(); ?>public/css/style.css">
	<script type="text/javascript" src="//cdn.bootcss.com/jquery/1.11.3/jquery.min.js"></script>
	<script type="text/javascript" src="<?=base_url()?>public/js/bootstrap.min.js"></script>
</head>
<body>
<?php $this->load->view('admin/heard')?>
<div class="container from ">
	<div class="page-header">
	  <h1>文章列表 <a class="pull-right btn btn-success" href="<?=site_url('/admin/article/add')?>">添加</a></h1>
	</div>
	<table class="table table-hover" cellpadding="0" cellspacing="0">
		<tr>
			<td>标题</td>
			<td>创建时间</td>
			<td>访问人数</td>
			<td>是否推荐</td>
			<td>修改操作</td>
		</tr>
		<?php if(empty($articles)){?><!--当数据库数据取完，输出没有数据-->
			<tr>
				<td class="empty" colspan='9'>没有数据</td>
			</tr>
		<?php }?>
	<?php	
	foreach($articles as $article) {
	?>	
		<tr> 
			<td><?=$article->title;?></td>
			<td><?=date("Y-m-d H:i:s",$article->create_time);?></td>
			<td><?php echo $article->view;?></td>
			<td>
				<a class="btn btn-primary btn-xs recommend" href="<?=site_url('/admin/article/recommend/'.$article->id.'/'.$article->recommend)?>"><?=$article->recommend==0?'推荐':'取消推荐'?>
				</a>
			</td>
			<td>
				<a class="btn btn-info btn btn-primary btn-xs edit" href="<?php echo site_url("admin/article/edit/".$article->id)?>">修改</a>&nbsp;
				<a class="btn btn-danger btn btn-primary btn-xs del"   href="<?php echo site_url("admin/article/del/".$article->id)?>">删除</a>
			</td>
		</tr>
	<?php	
	}
	?>
	</table>
	<?php echo $this->pagination->create_links();?>	
</div>
<div id="myModal" class="modal fade">
  <div class="modal-dialog">
    <div class="modal-content">
      <div class="modal-header">
        <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>
        <h4 class="modal-title">Modal title</h4>
      </div>
      <div class="modal-body">
        
      </div>
      <div class="modal-footer">
        <button type="button" class="btn btn-default" data-dismiss="modal">取消</button>
        <button type="button" class="btn btn-primary">保存修改</button>
      </div>
    </div><!-- /.modal-content -->
  </div><!-- /.modal-dialog -->
</div><!-- /.modal -->
<script type="text/javascript">
	$(function(){
		$(".recommend").click(function(){
			var href = $(this).attr('href');
			$.get(href,function(){
				location.reload();
			});
			return false;
		});
		$(".del").click(function(){
			if (confirm("是否删除？")) {
				var href = $(this).attr('href');
				$.get(href,function(){
					location.reload();
				});
			}
			return false;
		});
		$(".edit").click(function(){
			$.get($(this).attr('href'),function(data){
				$('#myModal .modal-body').html(data);
			$('#myModal').modal('show');
				
			})
			return false;
		});
	});
</script>
</body>
</html>